/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * <p>Project: javase - Dir5
 * <p>Powered by webrx On 2021-12-13 15:51:50
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Dir5 {
    public static int num = 0;
    public static int line = 0;

    int y = 3;

    public static void main(String[] args) throws IOException {
        count(new File("c:/javase"));
        System.out.println("共有" + num + "个java程序文件,共" + line + "行代码");
    }

    public static void count(File file) throws IOException {
        var fns = file.listFiles();
        for (File f : fns) {
            if (f.isDirectory()) {
                count(f);
            } else {
                if (f.getName().toLowerCase().endsWith(".java")) {
                    long row = new BufferedReader(new FileReader(f)).lines().count();
                    line += row;
                    System.out.println(f.getAbsolutePath() + String.format("[时间：%tF %<tT]，row:%d行", f.lastModified(), row));
                    ++num;
                }
            }
        }
    }
}
